import {
  createRouter,
  createWebHashHistory,
  type RouteLocationNormalized
} from "vue-router";
import Layout from "@/components/Layout/index.vue";
import ChkNum from "@/views/chkNum/index.vue";
import LotNews from "@/views/lotNews/index.vue";
import LckNum from "@/views/lckNum/index.vue";
import LotStats from "@/views/lotStats/index.vue";
import DrawHist from "@/views/drawHist/index.vue";
import LotDtl from "@/views/lotDtl/index.vue";
import NewsDtl from "@/views/newsDtl/index.vue";
import Scan from "@/views/scan/index.vue";
import DrawVid from "@/views/drawVid/index.vue";
import NProgress from "@/utils/progress";
// import { useCacheViewStore } from "@/store/modules/cachedView";

const routes: any[] = [
  {
    path: "/",
    name: "BasicLayout",
    component: Layout,
    children: [
      {
        path: "/",
        redirect: () => {
          return { path: "/chkNum" };
        }
      },
      {
        path: "/chkNum",
        name: "ChkNum",
        component: ChkNum
      },
      {
        path: "/lotNews",
        name: "LotNews",
        component: LotNews
      },
      {
        path: "/lckNum",
        name: "LckNum",
        component: LckNum
      },
      {
        path: "/lotStats",
        name: "LotStats",
        component: LotStats
      },
      {
        path: "/drawHist",
        name: "DrawHist",
        component: DrawHist
      },
      {
        path: "/lot/detail/:id",
        name: "lot-detail",
        component: LotDtl
      },
      {
        path: "/news/detail/:id",
        name: "news-detail",
        component: NewsDtl
      },
      {
        path: "video",
        name: "video-index",
        component: () => import("@/views/video/index.vue"),
        meta: {
          title: "video"
        }
      },
      {
        path: "/scan",
        name: "Scan",
        component: Scan
      },
      {
        path: "/drawVid",
        name: "DrawVid",
        component: DrawVid
      },
      {
        path: "/:pathMatch(.*)",
        name: "404",
        component: () => import("@/views/404/index.vue")
      }
    ]
  }
];
// 路由
const router = createRouter({
  history: createWebHashHistory(),
  routes
});

router.beforeEach((_to, _from, next) => {
  NProgress.start();
  next();
});

router.afterEach(() => {
  NProgress.done();
});
// 导出
export default router;
